<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>使用 for in 访问属性</title>
</head>

<body>
    <h1>JavaScript 对象属性</h1>
    <p id="demo"></p>
    <script>
        var txt = "";
        var person = { fname: "Bill", lname: "Gates", age: 62 };
        var x;
        for (x in person) {
            txt += person[x] + " ";
        }
        document.getElementById("demo").innerHTML = txt;
    </script>
</body>

</html>